Ordinarily, each of communication devices such as a server, client or a like connected to a network has a network address (hereinafter simply called an “address”). A communication device sets up a session with an address of a device of a party to be communicated with and carries out communication by sending or receiving a packet via the session.
It is not always necessary that an address assigned to each of communication devices is an address in one specified layer. For example, an address in a layer stacked directly above a lower layer can be mapped to an address in the lower layer. That is, for example, an IP (Internet Protocol) address in network layer can be mapped to a MAC (Media Access Control) address in data link layer. Also, a plurality of port numbers in transport layer can be mapped to one IP address. In communication devices, a packet can be received or transmitted by using an address assigned in any one of layers or its mapped address.
For example, in communication in the same domain (subnet), a communication device issues an ARP (Address Resolution Protocol) request for an IP address assigned to a communication device of a party to be communicated with. The communication device having the IP address returns a MAC address in response to the ARP request. The communication device having received the MAC address transmits a packet to the returned MAC address. Thus, by using the mapping of addresses in two layers, receipt and transmission of a packet between communication devices can be realized.
Although, in the descriptions below, for convenience of explanation, unless otherwise defined, an address denotes an IP address, the address is not limited only to IP address. Though the explanation is made assuming that communication is carried out between communication devices by using TCP (Transmission Control Protocol) as a communication protocol, there is no restriction on any protocol to be used between communication devices.
Next, operations of setting up a session between communication devices using the TCP are described briefly.
A communication device transmits a request for new connection to a communication device being a party to be communicated with to set up a bidirectional communication session. After that, via the session, data is transmitted and received between communication devices. The request for new connection using, for example, TCP begins with transmission of a SYN (Synchronized) packet. Then, a session is set up by operations referred to as a so-called “3-way handshake” process. At the time of setting up the session, an initial value of a sequence number is notified to each other between communication devices. When a communication device transmits a packet, sequence number of the packet is calculated by adding the initial value to a value corresponding to an amount of data of packets having been already transmitted. A receiver of the packet can check whether or not the packet has been received without a loss by confirming the sequence number of the received packet.
Next, a conventional switching device is described.
A communication system provided with the conventional switching system of this type is disclosed in Technical Reference 1 (F5 Network Japan, “BIG-IP Load Balancer 520”.
FIG. 18 is a block diagram showing a connection configuration of a conventional communication system provided with the switching device disclosed in the above Technical Reference 1. The communication system includes a switching device 121 connected in a local network 120, a plurality of servers 130-1˜130-n, a plurality of clients 100-1˜100-m, and a network 110 serving as a packet exchange network to connect the local network 120 to the clients 100-1˜100-m. 
The switching operations of the server by the conventional switching device 121 are described by referring to the connection configuration shown in FIG. 18 and also to FIG. 19 which is a sequence diagram showing operations of server switching by the conventional switching device. The client (hereinafter, explained by using the client 100-1, address 70.70.70.70 in FIG. 19) sets up a session with the switching device having system address (80.80.80.80 in FIG. 19) being a destination representing a plurality of servers 130-1˜130-n. 
The switching device 121 in the local network 120 performs load balancing on servers by dispatching requests to the servers 130-n. The switching device 121, when receiving a request for setting up a session from the client 100-1, sets up a session between the client 100-1 and switching device 121 in accordance with the 3-way handshake procedure (packets 1901, 1902, and not-shown ACK packet between 1902 and 1903 transmitted from the client 100-1 to the switching device 121 in FIG. 19). Then, a request to the server is transmitted from the client 100-1 to the switching device 121 (1903 in FIG. 19).
The switching device 121 selects a server from the plurality of servers according to some selecting criteria and dispatches a request from the client 100-1. The server may be selected by using the information used for communication control such as a source address or a like written in a header part of a packet as a criterion or by using the application level information contained in a payload part of a packet as a criterion. Although flexible dispatch of requests to servers is made possible in a unit of a session by using the application level information, the processing load on the switching device 121 becomes higher. Servers may be selected according to a round robin method by which requests are dispatched to different servers in order of arrival of the requests.
It is now assumed that the server 130-1 is selected by the switching device 121 as a server to which a request from the client 100-1 is dispatched.
The switching device 121 sets up a session between the switching device 121 and the server 130-1 according to the 3-way handshake procedure (in FIG. 19, packets 1904, 1905, and not-shown ACK packet between 1905 and 1906 transmitted from the switching device 121 to the server 130-1). Then, a request to a server is transmitted from the switching device 121 to the server 130-1 (1906 in FIG. 19).
The header part of a packet has header information including a destination address, destination port number, source address, source port number, communication protocol type, sequence number, and number of bytes (size) of a packet. Moreover, in FIG. 19, the port number, communication protocol type are not required for explanation of operations and, therefore, their descriptions are omitted accordingly. Though an ACK packet notifying a sequence number of the received packet is also transmitted, which causes drawings to be complicated and its description is omitted accordingly.
As shown in FIG. 19, the switching device 121, when dispatching a packet received from the client 100-1 at the sequence 1904 and thereafter, rewrites its destination address (in some cases, simply shown as “Dst” in drawings and hereinafter), its source address (in some cases, simply shown as “Src”), and its sequence number, all which are written on the header part of the packet and sends out the packet having the rewritten addresses, sequence number, or a like to the server 130-1.
More specifically, as shown in FIG. 19, the switching device 121 rewrites the Src of the header part of a packet from 70.70.70.70 (address of client 100-1) into 192.168.1.99 (address assigned to the switching device 121 in the local network 120). The Dst is also rewritten from 80.80.80.80 (system address representing the server 130-1˜130-n) into 192.168.1.100 (address of the selected server 130-1).
Hereinafter, operations of rewriting a sequence number in the switching device 121 are described.
A sequence number of a packet is determined for every session in a every transmitting direction of the session. A sequence number of a SYN packet (10000 shown in 1901 in FIG. 19) in settin up a session and a sequence number (30000 shown in 1902 in FIG. 19) of a SYN-ACK packet (1902 in FIG. 19) in response to the SYN packet are determined as initial values for their own direction and, thereafter, a value obtained by adding a size of a packet to the sequence numbers is attached as the sequence number to the packet for their own direction. In the case of a packet containing an SYN and of a FIN packet showing the termination of a session, even if its size is 0, the addition of one to the sequence number is stipulated in the TCP/IP protocol.
Similarly, for a session between the switching device 121 and the server 130-1, an initial value of a sequence number in a direction from the switching device 121 to the server 130-1 is determined (50000 shown in 1904 in FIG. 19) and an initial value of a sequence number in a direction from the server 130-1 to the switching device 121 is determined (80000 shown in 1905 in FIG. 19).
The switching device 121 stores a difference between an initial value in the direction from the switching device 121 to the server 130-1 and an initial value in the direction from the client 100-1 to the switching device 121. In the example in FIG. 19, the number 40000 being a difference between 50000 and 10000 is stored. Then, when the switching device 121 relays a packet following the packet 1903 in FIG. 19 having received from the client 100-1 and transmits the relayed packet to the server 130-1, the sequence number to be attached to the packet received from the client 100-1 is rewritten into a value obtained by adding the difference to the sequence number.
Similarly, the switching device 121 stores a difference between an initial value in the direction from the switching device 121 to the client 100-1 and an initial value in the direction from the server 130-1 to the switching device 121. In the example in FIG. 19, the number −50000 being a difference between 30000 and 80000 is stored. Then, when the switching device 121 relays a packet following the packet 1907 in FIG. 19 having received from the server 130-1 and transmits the relayed packet to the client 100-1, the sequence number attached to the packet received from the server 130-1 is rewritten into a value obtained by adding the difference to the sequence number.
The switching device 121 having received a response packet (1907 and 1909 in FIG. 19) from the selected server 130-1, transmits the packet, with rewriting its Src, Dst, and sequence number in the header information, to the client 100-1 (1908, 1910 in FIG. 19). The server 130-1, after having completed the transmission of all response packets, attaches a termination flag (FIN) for terminating a session to a packet and transmits the packet (1911 in FIG. 19). In response to this process, a packet having the FIN flag is transmitted from the switching device 121 to the server 130-1 (1912 in FIG. 19).
Further, the switching device 121 transmits a packet having a FIN flag (1913 in FIG. 19) to the client 100-1. The packet having the FIN flag (1914 in FIG. 19) is transmitted from the client 100-1 having received the packet having the FIN flag. Thus, the session between the client 100-1 and switching device 121 and the session between the switching device 121 and the server 130-1 are terminated.
As described above, in the conventional switching device, communication is established between a client and a server by setting up a session independently between the client and a switching device and between the switching device and the server and by rewriting header information of each packet in each session and relaying each packet so that the two sessions are seen logically as one session. The method for logically setting up a session by rewriting header information of a packet as described above is disclosed in Technical Reference 2 (David Malts et al., “TCP Splicing for Application Layer Proxy Performance” IBM Research Report, RC21139).
To rewrite the above header information, table management of NAT (Network Address Translator) information as shown in FIG. 20 is required. Specifically, it is necessary to include, in a field in the table, the information about a system address representing each of the servers 130-1˜130-n and, even when a number of each address in a local network assigned to the switching device is only one, as shown on the line 2001 in the table in FIG. 20, at least, the information about an address of a client (client address), port number of a client (client port number), port number on the switching device side between a switching device and a server (switching device port number), an address of a server to which a request is dispatched, a difference (value to be added in a direction to a server) in sequence number values to be added when a packet of a client is relayed to a server, and a difference (value to be added in a direction to a client) in sequence number values to be added when a packet is relayed from a server to a client. For example, when operations shown in FIG. 19 are performed, a value as described on the line 2002 in the table shown in FIG. 20 is stored as a field value for each field. A client address and client port number are information required for the switching device to identify a session between a client and switching device and a switching device port number are information required for the switching device to identify a session between the switching device and server.
When a new request is issued, a server is again selected and an entry is added to the table in FIG. 20 and, when a session is terminated, a corresponding entryis deleted from the table in FIG. 20.
The first problem of the above conventional technology is that the management of the NAT table for address conversion is complicated.
In the conventional server switching, an address is assigned to a server in a fixed manner and, therefore, when a server is switched, a process of replacing an address of a packet with another address is required. Due to this, whenever a server is switched without terminating the session, an address of an entry in the NAT table has to be changed. Additionally, when a sequence number used to manage the order of transmitting a packet is rewritten, it is necessary that information to be used for the rewriting is to be stored in the NAT table for the management.
The second problem is that load of rewriting a header of a packet is high. That is, in the conventional device, rewriting of a source address, destination address, sequence number of a packet, and other many values is required before transmission of the packet.
Therefore, an object of the present invention is to simplify the management of the NAT table required to switch communication devices such as a server.
Also, another object of the present invention is to decrease processes of rewriting a packet and to provide a server switching device having high efficiency.